package ar.com.smamc.common;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class Preferences {
	
	private Context context;
	private SharedPreferences sharedPreferences;
	private static final String APP_PREFERENCES = "smamcPreferences";
	private static final String ALGORITMO = "algoritmoAsignacion";
	private static final String TAMANO = "tamanoMemoria";
	private static final String COMPACTAR = "compactarMemoria";
	
	public Preferences(Context context) {
		this.context = context;
		this.sharedPreferences = this.context.getSharedPreferences(APP_PREFERENCES, Context.MODE_PRIVATE);
	}
	
	public int getAlgoritmoAsignacion() {
		return sharedPreferences.getInt(ALGORITMO, 0);
	}
	
	public int getTamanoMemoria() {
		return sharedPreferences.getInt(TAMANO, 0);
	}
	
	public boolean getCompactarMemoria() {
		return sharedPreferences.getBoolean(COMPACTAR, false);
	}
	
	public void setAlgoritmoAsignacion(int algoritmo){
		Editor editor = this.sharedPreferences.edit();
		editor.putInt(ALGORITMO, algoritmo);
		editor.commit();
	}
	
	public void setTamanoMemoria(int tamano) {
		Editor editor = this.sharedPreferences.edit();
		editor.putInt(TAMANO, tamano);
		editor.commit();
	}
	
	public void setCompactarMemoria(boolean compactar) {
		Editor editor = this.sharedPreferences.edit();
		editor.putBoolean(COMPACTAR, compactar);
		editor.commit();
	}

}
